﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using ChangeHope.Common;
using System.Data;
using System.Text.RegularExpressions;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        /// <summary>
        /// 商品列表
        /// </summary>
        /// <returns></returns>
        public string ProductFitting()
        {
            string mystyle = this.Label_Inserted;
            string str_ShowState = this.GetParamValue("YX:ShowState");//显示状态
            string str_ShowIdentifier = this.GetParamValue("YX:ShowIdentifier");////显示方式
            string str_CompositorType = this.GetParamValue("YX:CompositorType");//是否排序
            string str_CompositorField = this.GetParamValue("YX:CompositorField");//排序字段
            string str_ShowRows = this.GetParamValue("YX:ShowRows");//显示行数
            string str_ShowColumns = this.GetParamValue("YX:ShowColumns");//显示列数
            string NameCharacter = this.GetParamValue("YX:NameCharacter");//名称长度
            string str_WhetherPagination = this.GetParamValue("YX:WhetherPagination");//是否分页
            string Showhome = this.GetParamValue("YX:Showhome");//每页显示记录条数
            string str_TempletLayout = this.GetParamValue("YX:TempletLayout");//布局方式
            string WhetherOmit = this.GetParamValue("YX:WhetherOmit");//是否省略
            string ContentCharacter = this.GetParamValue("YX:ContentCharacter");//内容长度
            string IsStoreLabel = this.GetParamValue("YX:IsStoreLabel");//是否是店铺标签
            string str_SpecialModule = this.GetParamValue("YX:SpecialModule");
            string ProductClassId = this.GetParamValue("YX:ProductClassId");
            string order = "";
            string Comd = " ";//条件

            StringBuilder Shtml = new StringBuilder();
            #region 查询参数
            switch (str_SpecialModule)
            {
                case "1":
                    order = " [order by] pro_SaleNum desc";
                    break;
                default:
                    if (!string.IsNullOrEmpty(str_CompositorType))
                    {
                        string Field = "";
                        if (HttpContext.Current.Request["Link"] != null)
                        {
                            Field = HttpContext.Current.Request["Link"].ToString();
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(str_CompositorField))
                            {
                                Field = str_CompositorField;
                            }
                        }

                        if (HttpContext.Current.Request.QueryString["q_Sort"] != null && HttpContext.Current.Request.QueryString["q_Sort"] != string.Empty)
                        {
                            string Ord = StringHelper.InputTexts(HttpContext.Current.Request.QueryString["q_Sort"].ToString());
                            if (str_CompositorType == "0")
                            {
                                order = " [order by] " + Ord + " asc";
                            }
                            else if (str_CompositorType == "1")
                            {
                                order = " [order by] " + Ord + " Desc";
                            }
                        }
                        else
                        {
                            if (str_CompositorType == "0")
                            {
                                order = " [order by] " + Field + " asc";
                            }
                            else if (str_CompositorType == "1")
                            {
                                order = " [order by] " + Field + " desc";
                            }
                        }
                    }
                    break;
            }

            if (string.IsNullOrEmpty(str_ShowRows) && ValidateHelper.IsNumber(str_ShowRows))
            {
                str_ShowRows = "1";
            }
            if (string.IsNullOrEmpty(str_ShowColumns) && ValidateHelper.IsNumber(str_ShowColumns))
            {
                str_ShowColumns = "1";
            }
            int pagesize = Convert.ToInt32(str_ShowRows) * Convert.ToInt32(str_ShowColumns);

            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            #endregion
            int productId = ChangeHope.WebPage.PageRequest.GetQueryInt("q_productid");
            string sparContent = mystyle;
            if (productId > 0)
            {
                YXShop.BLL.Product.ProductSparepart proSpaBll = new YXShop.BLL.Product.ProductSparepart();
                List<YXShop.Model.Product.ProductSparepart> proSpaList = proSpaBll.GetSparepart(productId);
                if (proSpaList.Count > 0)
                {
                    for (int s = 0; s < proSpaList.Count; s++)
                    {
                        if (!string.IsNullOrEmpty(proSpaList[s].SparepartProduct.Trim()))
                        {
                            double preferentialPrice = Convert.ToDouble(proSpaList[s].FavourableLimit);
                            int preferentialType = proSpaList[s].FavourableType;
                            int buyMinCount = proSpaList[s].BuyMinCount;
                            int buyMaxCount = proSpaList[s].BuyMaxCount;

                            if (sparContent.Contains("[#Spe_GroupName]"))
                            {
                                sparContent = sparContent.Replace("[#Spe_GroupName]", "" + proSpaList[s].SparepartName + "<input name=\"SparepartId\" id=\"SparepartId\" type=\"hidden\" value=\"" + proSpaList[s].Id + "\" />");
                            }
                            if (sparContent.Contains("[#Buy_SparCount]"))
                            {
                                sparContent = sparContent.Replace("[#Buy_SparCount]", "" + buyMinCount + "-" + buyMaxCount + "");
                            }
                            Comd += " and pro_ID in (" + proSpaList[s].SparepartProduct + ")";
                            ChangeHope.DataBase.DataByPage dataPage = bll.GetList(order, pagesize, Comd);
                            int itemcount = 0;
                            if (dataPage.DataReader != null)
                            {
                                YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();

                                if (!string.IsNullOrEmpty(sparContent))
                                {
                                    string pattern = @"\{\#[\s\S]*?\#\}";
                                    string tempfinallyconent = sparContent;
                                    StringBuilder GetTemp = new StringBuilder();
                                    MatchCollection macths = Regex.Matches(tempfinallyconent, pattern);
                                    string Str_Tag = "";
                                    string temptag = "";
                                    foreach (Match macth in macths)
                                    {
                                        temptag = macth.ToString();
                                        int templength = temptag.ToString().IndexOf("{#") + 2;
                                        int templength2 = temptag.ToString().IndexOf("#}");
                                        if (temptag.ToString().Substring(templength, templength2 - templength).ToString() != null)
                                        {
                                            Str_Tag = temptag.ToString().Substring(templength, templength2 - templength);
                                        }
                                    }

                                    StringBuilder content = new StringBuilder();

                                    while (dataPage.DataReader.Read())
                                    {
                                        string strContent = string.Empty;
                                        if (Str_Tag != "")
                                        {
                                            strContent = "<div id='sparteparGroup" + proSpaList[s].Id + "'>" + Str_Tag + "<div>";
                                        }
                                        else
                                        {
                                            strContent = sparContent;
                                        }
                                        itemcount++;
                                        //替换标签
                                        #region 商品属性参数

                                        int ContentCharacterNu = 30, NameCharacterNu = 10;
                                        if (!string.IsNullOrEmpty(ContentCharacter) && ChangeHope.Common.ValidateHelper.IsNumber(ContentCharacter))
                                        {
                                            ContentCharacterNu = Convert.ToInt32(ContentCharacter);
                                        }
                                        if (!string.IsNullOrEmpty(NameCharacter) && ValidateHelper.IsNumber(NameCharacter))
                                        {
                                            NameCharacterNu = Convert.ToInt32(NameCharacter);
                                        }
                                        string Ellipsis = "...";
                                        if (WhetherOmit == "False")
                                        {
                                            Ellipsis = "";
                                        }

                                        string spareparProductId = dataPage.DataReader["pro_ID"].ToString();
                                        double price = Convert.ToDouble(dataPage.DataReader["pro_ShopPrice"].ToString());
                                        string memberPrice = dataPage.DataReader["pro_RatingDiscount"].ToString();
                                        string specificationValue = "";
                                        int productStock = Convert.ToInt32(dataPage.DataReader["pro_Stock"].ToString());
                                        if (!string.IsNullOrEmpty(dataPage.DataReader["pro_Specifications"].ToString()))
                                        {
                                            YXShop.BLL.Product.ProductSpecification proSpe = new YXShop.BLL.Product.ProductSpecification();
                                            List<YXShop.Model.Product.ProductSpecification> proSpeList = proSpe.GetSpecification(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                                            if (proSpeList.Count > 0)
                                            {
                                                price = Convert.ToDouble(proSpeList[0].SalePrice);
                                                memberPrice = proSpeList[0].MemberPrice;
                                                specificationValue = proSpeList[0].Specifications;
                                                productStock = proSpeList[0].ProductStock;
                                            }
                                        }
                                        if (HttpContext.Current.Session["MemberID"] != null && !string.IsNullOrEmpty(memberPrice.Trim()))
                                        {
                                            price = YXShop.Common.ProductInfo.DiscountedPrice(int.Parse(HttpContext.Current.Session["MemberID"].ToString()), price, memberPrice);
                                        }
                                        if (preferentialType == 0 && preferentialPrice > 0)
                                        {
                                            price = price * preferentialPrice;
                                        }
                                        else if (preferentialType == 1 && preferentialPrice > 0)
                                        {
                                            price = price - preferentialPrice;
                                        }

                                        if (strContent.Contains("[#Spe_Check]"))
                                        {
                                            strContent = strContent.Replace("[#Spe_Check]", "<input name=\"SparepartProductPrice" + spareparProductId + "\" name=\"SparepartProductPrice" + spareparProductId + "\" type=\"hidden\" value=\"" + price + "\" /><input name=\"SparepartCbx\" id=\"SparepartCbx\" type=\"checkbox\" onclick=\"Sparepar(" + spareparProductId + "," + buyMinCount + "," + buyMaxCount + ")\" value=\"" + spareparProductId + "\"/>");
                                        }
                                        if (strContent.Contains("[#Buy_Count]"))
                                        {
                                            strContent = strContent.Replace("[#Buy_Count]", "<input type=\"text\" id=\"SpareparProductCount" + spareparProductId + "\" name=\"SpareparProductCount" + spareparProductId + "\" size=\"9\" value=\"" + buyMinCount + "\"  onblur=\"Sparepar(" + spareparProductId + "," + buyMinCount + "," + buyMaxCount + ")\"/>");
                                        }

                                        if (strContent.Contains("[#Product_Name]"))
                                        {
                                            string specVa = "";
                                            if (specificationValue != "")
                                            {
                                                specVa = "[" + specificationValue + "]";
                                            }
                                            strContent = strContent.Replace("[#Product_Name]", "" + ChangeHope.Common.StringHelper.SubStringAndAppend(dataPage.DataReader["pro_Name"].ToString(), NameCharacterNu, Ellipsis) + "" + specVa + "");//商品名称

                                        }
                                        if (strContent.Contains("[#Product_No]"))
                                        {
                                            strContent = strContent.Replace("[#Product_No]", dataPage.DataReader["pro_NO"].ToString());
                                        }

                                        if (strContent.Contains("[#Product_Key]"))
                                        {
                                            if (dataPage.DataReader["pro_KeyWord"].ToString() != null)
                                            {

                                                strContent = strContent.Replace("[#Product_Key]", dataPage.DataReader["pro_KeyWord"].ToString());//关键字
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Key]", "");//关键字
                                            }
                                        }
                                        if (strContent.Contains("[#Product_PickDownTime]"))
                                        {
                                            if (dataPage.DataReader["pro_AutoDown"].ToString() != null)
                                            {

                                                strContent = strContent.Replace("[#Product_PickDownTime]", dataPage.DataReader["pro_AutoDown"].ToString());//下架时间
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_PickDownTime]", "");//下架时间
                                            }
                                        }
                                        if (strContent.Contains("[#Product_MeasureUnit]"))
                                        {
                                            if (dataPage.DataReader["pro_Unit"].ToString() != null && dataPage.DataReader["pro_Unit"].ToString() != "0")
                                            {

                                                strContent = strContent.Replace("[#Product_MeasureUnit]", dataPage.DataReader["pro_Unit"].ToString());//商品单位
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_MeasureUnit]", "");//商品单位
                                            }
                                        }
                                        if (strContent.Contains("[#Product_Introduction]"))
                                        {
                                            if (dataPage.DataReader["pro_Synopsis"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_Introduction]", "" + ChangeHope.Common.StringHelper.SubStringAndAppend(dataPage.DataReader["pro_Synopsis"].ToString(), ContentCharacterNu, Ellipsis) + "");//商品简介
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Introduction]", "");//商品简介
                                            }
                                        }
                                        if (strContent.Contains("[#Product_ShopPrice]"))
                                        {
                                            if (dataPage.DataReader["pro_ShopPrice"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_ShopPrice]", price.ToString("f2"));//商品商城价
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_ShopPrice]", "0");//商品商城价
                                            }
                                        }
                                        if (strContent.Contains("[#Product_MarketPrice]"))
                                        {
                                            if (dataPage.DataReader["pro_MarketPrice"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_MarketPrice]", dataPage.DataReader["pro_MarketPrice"].ToString());//商品市场价
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_MarketPrice]", "");//商品市场价
                                            }
                                        }
                                        if (strContent.Contains("[#Product_Spread]"))
                                        {
                                            double marketPrice = Convert.ToDouble(dataPage.DataReader["pro_MarketPrice"].ToString());
                                            strContent = strContent.Replace("[#Product_Spread]", (marketPrice - price).ToString("f2"));
                                        }
                                        if (strContent.Contains("[#Product_Thumbnails]"))
                                        {
                                            if ((dataPage.DataReader["pro_Thumbnail"].ToString() != null) && (dataPage.DataReader["pro_Thumbnail"].ToString() != ""))
                                            {
                                                strContent = strContent.Replace("[#Product_Thumbnails]", sp.DummyPaht + dataPage.DataReader["pro_Thumbnail"].ToString());//商品缩略图
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Thumbnails]", sp.DummyPaht + "images/NaughtImages.gif");//商品缩略图

                                            }
                                        }
                                        if (strContent.Contains("[#Product_Bigmap]"))
                                        {
                                            if ((dataPage.DataReader["pro_Images"].ToString() != null) && (dataPage.DataReader["pro_Images"].ToString() != ""))
                                            {
                                                strContent = strContent.Replace("[#Product_Bigmap]", sp.DummyPaht + dataPage.DataReader["pro_Images"].ToString());//商品大图
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Bigmap]", sp.DummyPaht + "images/NaughtImages.gif");//商品大图

                                            }
                                        }

                                        if (strContent.Contains("[#Product_Weight]"))
                                        {
                                            if (dataPage.DataReader["pro_Weight"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_Weight]", dataPage.DataReader["pro_Weight"].ToString());//商品重量
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Weight]", "");//商品重量

                                            }
                                            if (strContent.Contains("[#Product_Units]"))
                                            {
                                                if (dataPage.DataReader["pro_WeightUnit"].ToString() != null)
                                                {
                                                    string weightUnit = dataPage.DataReader["pro_WeightUnit"].ToString() == "1" ? "千克" : "克";
                                                    strContent = strContent.Replace("[#Product_Units]", weightUnit);//商品重量单位
                                                }
                                                else
                                                {
                                                    strContent = strContent.Replace("[#Product_Units]", "");//商品重量单位

                                                }
                                            }
                                        }

                                        if (strContent.Contains("[#Product_Stock]"))
                                        {
                                            if (dataPage.DataReader["pro_Stock"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_Stock]", productStock.ToString());//商品库存
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_Stock]", "");//商品库存

                                            }
                                        }
                                        if (strContent.Contains("[#Product_ShelvesCount]"))
                                        {
                                            if (dataPage.DataReader["pro_AuditCount"].ToString() != null)
                                            {
                                                strContent = strContent.Replace("[#Product_ShelvesCount]", dataPage.DataReader["pro_AuditCount"].ToString());//商品上架数量
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Product_ShelvesCount]", "");//商品上架数量

                                            }
                                        }
                                        #endregion

                                        #region 点卡
                                        if (str_ShowIdentifier == "7")
                                        {
                                            YXShop.BLL.OrderCard.OrderCardInfo oribll = new YXShop.BLL.OrderCard.OrderCardInfo();
                                            YXShop.Model.OrderCard.OrderCardInfo orimodel = oribll.GetModelID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                                            string FaceValue = string.Empty;
                                            string Price = string.Empty;
                                            string Point = string.Empty;
                                            string Unit = string.Empty;
                                            string ExpirationDate = string.Empty;
                                            string BusinessAgent = string.Empty;
                                            if (orimodel != null)
                                            {
                                                FaceValue = orimodel.FaceValue.ToString();
                                                Price = orimodel.Price.ToString();
                                                Point = orimodel.Point;
                                                Unit = orimodel.Unit;
                                                ExpirationDate = orimodel.ExpirationDate.ToString();
                                                BusinessAgent = orimodel.BusinessAgent;
                                            }
                                            if (strContent.Contains("[#card_FaceValue]"))
                                            {
                                                strContent = strContent.Replace("[#card_FaceValue]", FaceValue);
                                            }
                                            if (strContent.Contains("[#card_Price]"))
                                            {
                                                strContent = strContent.Replace("[#card_Price]", Price);
                                            }
                                            if (strContent.Contains("[#card_Point]"))
                                            {
                                                strContent = strContent.Replace("[#card_Point]", Point);
                                            }
                                            if (strContent.Contains("[#card_Unit]"))
                                            {
                                                strContent = strContent.Replace("[#card_Unit]", Unit);
                                            }
                                            if (strContent.Contains("[#card_ExpirationDate]"))
                                            {
                                                strContent = strContent.Replace("[#card_ExpirationDate]", ExpirationDate);
                                            }
                                            if (strContent.Contains("[#card_BusinessAgent]"))
                                            {
                                                strContent = strContent.Replace("[#card_BusinessAgent]", BusinessAgent);
                                            }
                                            orimodel = null;

                                        }
                                        #endregion

                                        #region 团购
                                        if (str_ShowIdentifier == "3")
                                        {
                                            YXShop.BLL.Product.Product_IntegratePurchas pipbll = new YXShop.BLL.Product.Product_IntegratePurchas();
                                            YXShop.Model.Product.Product_IntegratePurchas pipmodel = pipbll.GetModelProductID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                                            string StartTime = string.Empty;
                                            string EndTime = string.Empty;
                                            string Deposit = string.Empty;
                                            string BuyCount = string.Empty;
                                            string DonateIntegral = string.Empty;
                                            string PriceLevel = string.Empty;
                                            string Description = string.Empty;
                                            if (pipmodel != null)
                                            {
                                                StartTime = pipmodel.StartTime.ToString();
                                                EndTime = pipmodel.EndTime.ToString();
                                                Deposit = pipmodel.Deposit.ToString();
                                                BuyCount = pipmodel.Count.ToString();
                                                DonateIntegral = pipmodel.DonateIntegral.ToString();
                                                string[] LadderCount = pipmodel.LadderCount.Split(',');
                                                string[] LadderPrice = pipmodel.LadderPrice.Split(',');
                                                string ProductUnit = "";
                                                if (dataPage.DataReader["pro_Unit"].ToString() != "0")
                                                {
                                                    ProductUnit = dataPage.DataReader["pro_Unit"].ToString();
                                                }
                                                for (int l = 0; l < LadderCount.Length; l++)
                                                {
                                                    PriceLevel += "团购数量达到：" + LadderCount[l] + ProductUnit + "，享受价格为：" + LadderPrice[l] + "<br>";
                                                }
                                                Description = pipmodel.Description;

                                            }
                                            if (strContent.Contains("[#GroupBuy_StartTime]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_StartTime]", StartTime);

                                            }
                                            if (strContent.Contains("[#GroupBuy_EndTime]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_EndTime]", EndTime);
                                            }
                                            if (strContent.Contains("[#GroupBuy_Deposit]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_Deposit]", Deposit);
                                            }
                                            if (strContent.Contains("[#GroupBuy_BuyCount]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_BuyCount]", BuyCount);
                                            }
                                            if (strContent.Contains("[#GroupBuy_DonateIntegral]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_DonateIntegral]", DonateIntegral);
                                            }
                                            if (strContent.Contains("[#GroupBuy_PriceLevel]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_PriceLevel]", PriceLevel);
                                            }
                                            if (strContent.Contains("[#GroupBuy_Description]"))
                                            {
                                                strContent = strContent.Replace("[#GroupBuy_Description]", Description);
                                            }
                                        }
                                        #endregion

                                        #region 拍卖
                                        if (str_ShowIdentifier == "5")
                                        {
                                            YXShop.BLL.Product.ProductAuction pabll = new YXShop.BLL.Product.ProductAuction();
                                            YXShop.Model.Product.ProductAuction pamodel = pabll.GetModelProductID(Convert.ToInt32(dataPage.DataReader["pro_ID"].ToString()));
                                            string AuctionName = string.Empty;
                                            string StartTime = string.Empty;
                                            string EndTime = string.Empty;
                                            string Price = string.Empty;
                                            string PriceRange = string.Empty;
                                            string Deposit = string.Empty;
                                            string Description = string.Empty;
                                            if (pamodel != null)
                                            {
                                                AuctionName = pamodel.AuctionName;
                                                StartTime = pamodel.StartTime.ToString();
                                                EndTime = pamodel.EndTime.ToString();
                                                Price = pamodel.Price.ToString();
                                                PriceRange = pamodel.PriceRange.ToString();
                                                Deposit = pamodel.Deposit.ToString();
                                                Description = pamodel.Description;
                                            }

                                            if (strContent.Contains("[#Auction_Name]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_Name]", AuctionName);
                                            }
                                            if (strContent.Contains("[#Auction_StartTime]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_StartTime]", StartTime);
                                            }
                                            if (strContent.Contains("[#Auction_EndTime]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_EndTime]", EndTime);
                                            }
                                            if (strContent.Contains("[#Auction_StartPrice]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_StartPrice]", Price);
                                            }
                                            if (strContent.Contains("[#Auction_AddLevel]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_AddLevel]", PriceRange);
                                            }
                                            if (strContent.Contains("[#Auction_Deposit]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_Deposit]", Deposit);
                                            }
                                            if (strContent.Contains("[#Auction_Description]"))
                                            {
                                                strContent = strContent.Replace("[#Auction_Description]", Description);
                                            }
                                        }
                                        #endregion

                                        #region 操作方式
                                        if (strContent.Contains("[#Option_Src]"))
                                        {
                                            strContent = strContent.Replace("[#Option_Src]", Common.UrlStr("productcontent", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                                        }
                                        if (strContent.Contains("[#Option_GroupBuyURL]"))
                                        {
                                            strContent = strContent.Replace("[#Option_GroupBuyURL]", Common.UrlStr("product_groupbuy_content", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                                        }
                                        if (strContent.Contains("[#Option_AuctionURL]"))
                                        {
                                            strContent = strContent.Replace("[#Option_AuctionURL]", Common.UrlStr("product_auction_content", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "product/"));
                                        }
                                        if (strContent.Contains("[#Option_Buy]"))
                                        {
                                            if (productStock < 1)
                                            {
                                                strContent = strContent.Replace("[#Option_Buy]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/bottomWheelbarrow.gif' /><span style='COLOR: #666666;'><a href=\"#\">购买</a></span>");
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#Option_Buy]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/bottomWheelbarrow.gif' /><span style='COLOR: #666666;'><a href=\"javascript:FittingShopCar('" + sp.DummyPaht + "'," + dataPage.DataReader["pro_ID"].ToString() + ",'" + specificationValue + "')\">购买</a></span>");
                                            }
                                        }
                                        if (strContent.Contains("[#Option_Favorites]"))
                                        {
                                            strContent = strContent.Replace("[#Option_Favorites]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/sC.gif' /><span style='COLOR: #666666;'><a href=\"" + Common.UrlStr("collection", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "filehandle/") + "\">收藏</a></span>");
                                        }
                                        if (strContent.Contains("[#Option_Comparison]"))
                                        {
                                            strContent = strContent.Replace("[#Option_Comparison]", "<img  src='" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/compare1.gif'  id=\"pcheck_131\" onclick=\"addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')\"/><span style='COLOR: #666666;'><a href=\"javascript:addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')\"  id=\"pcheck_131\" >比较</a></span>");

                                        }
                                        //图片路径
                                        if (strContent.Contains("[#DummyPahtAndTemplatePaht]"))
                                        {
                                            strContent = strContent.Replace("[#DummyPahtAndTemplatePaht]", sp.DummyPaht + sp.WebSiteTemplatePath);
                                        }
                                        //购买链接
                                        if (strContent.Contains("[#BuyUrl]"))
                                        {
                                            if (productStock < 1)
                                            {
                                                strContent = strContent.Replace("[#BuyUrl]", "#");
                                            }
                                            else
                                            {
                                                strContent = strContent.Replace("[#BuyUrl]", "javascript:FittingShopCar('" + sp.DummyPaht + "'," + dataPage.DataReader["pro_ID"].ToString() + ",'" + specificationValue + "')");
                                            }
                                        }
                                        //收藏链接
                                        if (strContent.Contains("[#CollectionUrl]"))
                                        {
                                            strContent = strContent.Replace("[#CollectionUrl]", Common.UrlStr("collection", "q_productid=" + dataPage.DataReader["pro_ID"].ToString() + "", "filehandle/"));
                                        }
                                        //比较
                                        if (strContent.Contains("[#ComparisonUrl]"))
                                        {
                                            strContent = strContent.Replace("[#ComparisonUrl]", "javascript:addToCompare(this," + dataPage.DataReader["pro_ID"].ToString() + ",'" + dataPage.DataReader["pro_Name"].ToString() + "')");

                                        }
                                        #endregion


                                        content.Append(strContent);
                                        if (str_TempletLayout == "1")
                                        {
                                            if ((itemcount % Convert.ToInt32(str_ShowColumns)) == 0)
                                            {
                                                content.Append("</tr><tr>");
                                            }
                                            else
                                            {
                                                content.Append("</td><td>");
                                            }
                                        }

                                    }

                                    if (Str_Tag != "")
                                    {
                                        if (content.ToString() != string.Empty)
                                        {
                                            sparContent = sparContent.Replace(temptag, content.ToString());
                                        }
                                        else
                                        {
                                            sparContent = sparContent.Replace(temptag, "");
                                        }
                                        Shtml.Append(sparContent);
                                    }
                                    else
                                    {
                                        Shtml.Append(content.ToString());
                                    }

                                }
                            }
                            dataPage.Dispose();
                            dataPage = null;
                        }
                    }
                }
            }


            if (str_TempletLayout == "1")
            {
                return "<table width='100%'>" + Shtml.ToString() + "</table>";
            }
            return Shtml.ToString();
        }


    }
}

